package sw6.digipecs.model;

import sw6.digipecs.database.SentenceBoardStateCursor;
import sw6.digipecs.exceptions.IDNotFoundException;
import android.content.Context;

public class ExtImageInSentenceBoard extends ExtImage {
	
	private boolean mLocked = false;
	
	public ExtImageInSentenceBoard(Context context) {
		super(context);
	}
	
	public ExtImageInSentenceBoard(Context context, int id) throws IDNotFoundException {
		super(context, id);
	}

	public ExtImageInSentenceBoard(Context context, int id, int index) throws IDNotFoundException {
		super(context, id);
		
		mDB.open();
		
		SentenceBoardStateCursor cursor = mDB.fetchSentenceBoardItem(index);
		if (cursor.moveToFirst()) {
			mLocked = cursor.getSentenceBoardStateLock();
		} else {
			cursor.close();
			mDB.close();
			throw new IDNotFoundException();
		}
		
		cursor.close();
		mDB.close();
	}

	public boolean isLocked() {
		return mLocked;
	}

}
